var express = require('express');
var router = express.Router();
let { gomodel } = require('../model/model')
/* GET home page. */
router.get('/gooodlist', async (req, res) => {
    let { id,page } = req.query
    console.log(id)
    // 使用管道符，查找数据，并关联分类表
    let data = await gomodel.find({ s_id: id }).skip((page-1)*10).limit(10)
    res.send({
        code:200,
        data
    })
});

router.get("/searchgoods", async (req, res) => {
    let { searchname } = req.query
    let data = await gomodel.find({
        $or: [
            { name: { $regex: searchname } },
        ]
    })
    res.send({
        code: 200,
        data
    })
}) 

module.exports = router;
